package www.wen.com.common.lib.data.entities


import android.os.Parcelable
import androidx.annotation.Keep
import com.chad.library.adapter.base.entity.node.BaseExpandNode
import com.chad.library.adapter.base.entity.node.BaseNode
import kotlinx.parcelize.Parcelize

@Keep
@Parcelize
data class ServerGroupEntity(
        val content: List<Content>,
        val empty: Boolean, // false
        val first: Boolean, // true
        val last: Boolean, // true
        val number: Int, // 0
        val numberOfElements: Int, // 2
        val pageable: String, // INSTANCE
        val size: Int, // 0
        val sort: Sort,
        val totalElements: Int, // 2
        val totalPages: Int, // 1
) : Parcelable {
    @Keep
    @Parcelize
    data class Content(
            val channelVO: List<ChannelVO>,
            val createTime: String, // 2021-09-15T11:04:03.000+0800
            val groupId: Int, // 39
            var groupName: String, // 规则和公告
            val groupSort: Int, // 1
            val groupType: String, // 1
            val serverId: String, // T86151037
            val updateTime: String, // 2021-09-15T11:04:03.000+0800

            //本地字段
            var ownUserId:String?,
    ) : BaseExpandNode(), Parcelable {


        init {
            isExpanded = true
        }

        override val childNode: MutableList<BaseNode>
            get() {
                val nodes = mutableListOf<BaseNode>()
                channelVO.forEach {
                    nodes.add(it)
                }
                return nodes
            }

        @Keep
        @Parcelize
        data class ChannelVO(
                val channelDesc: String,
                val channelId: Long, // 20
                val channelName: String, // 规则
                val channelSort: Int, // 0
                val channelType: String, // 1
                val createTime: String, // 2021-09-15T11:04:04.000+0800
                val groupId: Int, // 39
                val ownerId: String, // T65562628
                val teamId: String, // 3919995724
                val updateTime: String, // 2021-09-15T11:04:04.000+0800
                val serverId: String, // T83502785
                val topStatus: Boolean, // false

                //本地字段-未读消息
                var unreadCount: Int?,
                //本地字段-所属分组是否支持编辑
                var groupType: String?, // 1
                //本地字段-所属分组选择
                var isSelect: Boolean?,
        ) : BaseNode(), Parcelable {

            override val childNode: MutableList<BaseNode>?
                get() = null

            override fun equals(other: Any?): Boolean {
                if (this === other) return true
                return if (other is ChannelVO) {
                    teamId == other.teamId
                }else{
                    false
                }
            }

        }


    }

    @Keep
    @Parcelize
    data class Sort(
            val empty: Boolean, // true
            val sorted: Boolean, // false
            val unsorted: Boolean, // true
    ) : Parcelable
}